package com.ruoyi.SysWrong.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.SysWrong.domain.SysWrong;
import com.ruoyi.SysWrong.service.ISysWrongService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

/**
 * 历史记录Controller
 * 
 * @author ruoyi
 * @date 2024-03-20
 */
@RestController
@RequestMapping("/SysWrong/wrong")
@Tag(name = "【历史记录】管理")
public class SysWrongController extends BaseController
{
    @Autowired
    private ISysWrongService sysWrongService;

    /**
     * 查询历史记录列表
     * /SysWrong/wrong/list
     */
    @Operation(summary = "查询历史记录列表")
    @PreAuthorize("@ss.hasPermi('SysWrong:wrong:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysWrong sysWrong)
    {
        startPage();
        List<SysWrong> list = sysWrongService.selectSysWrongList(sysWrong);
        return getDataTable(list);
    }

    /**
     * 导出历史记录列表
     * /SysWrong/wrong/export
     */
    @Operation(summary = "导出历史记录列表")
    @PreAuthorize("@ss.hasPermi('SysWrong:wrong:export')")
    @Log(title = "历史记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysWrong sysWrong)
    {
        List<SysWrong> list = sysWrongService.selectSysWrongList(sysWrong);
        ExcelUtil<SysWrong> util = new ExcelUtil<SysWrong>(SysWrong.class);
        util.exportExcel(response, list, "历史记录数据");
    }

    /**
     * 获取历史记录详细信息
     * /SysWrong/wrong/{id}
     */
    @Operation(summary = "获取历史记录详细信息")
    @PreAuthorize("@ss.hasPermi('SysWrong:wrong:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysWrongService.selectSysWrongById(id));
    }

    /**
     * 新增历史记录
     * /SysWrong/wrong
     */
    @Operation(summary = "新增历史记录")
    @PreAuthorize("@ss.hasPermi('SysWrong:wrong:add')")
    @Log(title = "历史记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysWrong sysWrong)
    {
        return toAjax(sysWrongService.insertSysWrong(sysWrong));
    }

    /**
     * 修改历史记录
     */
    @Operation(summary = "修改历史记录")
    @PreAuthorize("@ss.hasPermi('SysWrong:wrong:edit')")
    @Log(title = "历史记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysWrong sysWrong)
    {
        return toAjax(sysWrongService.updateSysWrong(sysWrong));
    }

    /**
     * 删除历史记录
     */
    @Operation(summary = "删除历史记录")
    @PreAuthorize("@ss.hasPermi('SysWrong:wrong:remove')")
    @Log(title = "历史记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable( name = "ids" ) Long[] ids) 
    {
        return toAjax(sysWrongService.deleteSysWrongByIds(ids));
    }
}
